package cv.ltq.oauth2_demo.controller;

import org.springframework.security.oauth2.client.authentication.OAuth2AuthenticationToken;
import org.springframework.security.oauth2.core.OAuth2AccessToken;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class UserController {

    //登录成功之后的处理
    @GetMapping("/successLogin")
    @ResponseBody //不走视图解析器，直接打印在浏览器
    public  String successLogin(OAuth2AuthenticationToken token){
        System.out.println(String .valueOf(token));
        //输出用户信息
        return "欢迎你,gitee用户:"+token.getPrincipal().getAttributes().get("login");
    }
}
